package com.mobimap.nhom9.bus;

import java.util.List;

import android.content.Context;
import android.util.Log;

import com.mobimap.nhom9.dto.NodeInfoDTO;
import com.mobimap.nhom9.dto.PlaceExDTO;

class DirectionBUS implements IDirectionBUS {
	private PlaceExDTO firstPlace;
	private PlaceExDTO endPlace;
	private Context mContext;
	
	public DirectionBUS(Context mContext) {
		this.mContext = mContext;
		this.checkDirectionLocation();
	}
	
	public PlaceExDTO getFirstPlace() {
		return firstPlace;
	}

	public void setFirstPlace(PlaceExDTO firstPlace) {
		this.firstPlace = firstPlace;
		this.checkDirectionLocation();
	}

	public PlaceExDTO getEndPlace() {
		return endPlace;
	}

	public void setEndPlace(PlaceExDTO endPlace) {
		this.endPlace = endPlace;
	}

	/**
	 * @region - Helper
	 */
	private void checkDirectionLocation()	{
		if (this.firstPlace != null
				&& this.endPlace != null)	{
			ISearchEngine searchEngine = MobimapProvider.getSearchEngine(mContext);
			List<NodeInfoDTO> lstNodeInfo = searchEngine.timDuong(this.firstPlace.getLocation(), this.endPlace.getLocation());
			for (NodeInfoDTO nodeInfoDTO : lstNodeInfo) {
				Log.e("TIMDUONG", nodeInfoDTO.toString());
			}
			this.firstPlace = null;
			this.endPlace = null;
		}
	}
}
